package com.audaque.springboot.foshanupload.schedule.impl;


import com.audaque.springboot.foshanupload.schedule.iface.DynamicScheduleIface;
import lombok.*;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class DynamicScheduleImpl implements DynamicScheduleIface {
    private long id;

    private String cron;

    private boolean open;

    private String reference;



    @Override
    public boolean open() {
        return this.open;
    }

    @Override
    public boolean isChange(DynamicScheduleIface oldTaskInfo) {
        if(oldTaskInfo instanceof DynamicScheduleImpl) {
            final DynamicScheduleImpl obj = (DynamicScheduleImpl) oldTaskInfo;
            return !this.cron.equals(obj.cron) || this.open != obj.open || !this.reference.equals(obj.getReference());
        } else {
            throw new IllegalArgumentException("Not Support SchedulerTestTaskInfo type");
        }
    }
}
